<?php ob_start();
include("../config/config.php"); 

if (!empty($_GET['openid_ext1_value_firstname']) && !empty($_GET['openid_ext1_value_lastname']) && !empty($_GET['openid_ext1_value_email'])) {    
    $username = $_GET['openid_ext1_value_firstname'] . $_GET['openid_ext1_value_lastname'];
    $email = $_GET['openid_ext1_value_email'];

	$chk=mysql_query("SELECT * FROM `my_user` WHERE `email`='".$email."' ")or die(mysql_error());	
	if(!mysql_num_rows($chk)){
		$sql=mysql_query("INSERT INTO `my_user` SET `fname`='".$_GET['openid_ext1_value_firstname']."',
													`lname`='".$_GET['openid_ext1_value_lastname']."',
													`email`='".$_GET['openid_ext1_value_email']."' ")or die(mysql_error());
		$id=mysql_insert_id();
		if($sql){ 
			$sql2=mysql_query("SELECT * FROM `my_user` WHERE `id`=$id ")or die(mysql_error());	
			$rows=mysql_fetch_array($sql2);
			$_SESSION['id']=	$rows['id'];
			$_SESSION['fname']=	$rows['fname'];
			if(isset($_SESSION['business_url'])&&($_SESSION['business_url']!="")){
				header("location:../dashboard.php"); exit;
			}else{
				header("location:http://mycitydial.com"); exit;
			}
		}
	}else{
		$sql2=mysql_query("SELECT * FROM `my_user` WHERE `email`='".$email."' ")or die(mysql_error());	
		$rows=mysql_fetch_array($sql2);
		$_SESSION['id']=	$rows['id'];
		$_SESSION['fname']=	$rows['fname'];
		if(isset($_SESSION['business_url'])&&($_SESSION['business_url']!="")){
			header("location:../dashboard.php"); exit;
		}else{
			header("location:http://mycitydial.com"); exit;
		}
	}	

}else{header("location:../index.php"); exit;}
?>
